package com.intsig.airflow.web.util;

import java.lang.reflect.Array;

/**
 * @author leojie 2021/3/13 10:47 下午
 */
public class ReflectUtil {
    public static int[] changeObjToIntArr(Object obj) {
        if (obj == null) {
            return new int[]{};
        }
        try {
            if (obj.getClass().isArray()) {
                int length = Array.getLength(obj);
                int[] intArr = new int[length];
                for (int i = 0; i < intArr.length; i++) {
                    intArr[i] = Integer.parseInt(Array.get(obj, i).toString());
                }
                return intArr;
            }
            return new int[]{};
        } catch (Exception e) {
            return new int[]{};
        }
    }
}
